package com.ddf.testDemo;

import java.util.Collection;

import org.junit.After;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.ddf.dao.UserDao;
import com.ddf.entity.User;

public class UserDaoTest extends Configration{
	private Logger log = LoggerFactory.getLogger(this.getClass());
	@Autowired
	private UserDao userDao;
	
	@Test
	@After
	public void testgetAllUser() {
		Collection<User> userList = userDao.getAllUser();
		for(User user : userList) {
			log.info(user.toString());
			log.info("---------------");
		}
	}
	
	@Test
	public void testAddUser() {
		User user = new User();
		user.setUserName("ddf05");
		user.setPassword("12345605");
		user.setSex("nan");
		user.setEmail("ddf05@123.com");
		userDao.addUser(user);
	}
	
	@Test
	public void testUpdateUser() {
		Integer id = 1;
		User user = userDao.getUserById(id);
		user.setUserName("updateDDF01");
		userDao.updateUser(user);
	}
	
	@Test
	public void testDeleteUser() {
		Integer id = 2;
		userDao.deleteUser(id);
	}
}
